home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Unix / satan-1.1.1 / bin / tcpscan.satan < prev    next >
Text File  |  1996-04-24  |  1KB  |  57 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # version 1, Mon Mar 20 18:44:32 1995, last mod by wietse
  4. #
  5.  
  6. #
  7. # Report TCP services (banners where possible).
  8. #
  9. require 'config/paths.pl';
  10. require 'perl/misc.pl';
  11. require 'perllib/getopts.pl';
  12.  
  13. $usage = "usage $0 [-v] ports target";
  14.  
  15. &Getopts("v") || die $usage;
  16. die $usage unless ($#ARGV == 1);
  17.  
  18. ($services = $ARGV[0]) =~ tr /,/ /;
  19. $target = $ARGV[1];
  20.  
  21. $severity = "x";
  22. $status = "a";
  23.  
  24. $| = 1; 
  25.  
  26. open(SERVICES, $SERVICES) || die "$0: cannot open $SERVICES: $!\n";
  27. while (<SERVICES>) {
  28.     $service_name{$2} = $1 if /(\S+)\s+([0-9]+)\/tcp/;
  29. }
  30. close(SERVICES);
  31.  
  32. $command = "$TCP_SCAN -bs 'QUIT\\r\\n' $target $services";
  33.  
  34. print "$command\n" if $opt_v;
  35.  
  36. open(TCP_SCAN, "$command|")
  37.     || die "$0: cannot run $TCP_SCAN";
  38.  
  39. while(<TCP_SCAN>) {
  40.     if (defined($opt_v)) {
  41.         print;
  42.     }
  43.     chop;
  44.     s/^600([0-9]):[^:]*/600$1:X-$1/;
  45.     s/^60([1-9][0-9]):[^:]*/60$1:X-$1/;
  46.     ($port, $service, $flag, $service_output) = split(/:/, $_, 4);
  47.     $service = $service_name{$port} if $service_name{$port};
  48.     if ($flag =~ /t/ && $port != 23 && $service_output) {
  49.         $service = "telnet on port $port";
  50.     } elsif ($service eq "UNKNOWN") { 
  51.         $service = "$port:TCP"; 
  52.     }
  53.     $service_output =~ y/|/?/;
  54.     $text = "offers $service";
  55.     &satan_print();
  56. }
  57.